package com.itheima.reggie.controller;

import com.itheima.reggie.comon.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dish")
public class DishController {
    @Autowired
    private DishService dishService;

    //查询对应的菜品
    @GetMapping("/list")
    @Cacheable(value = "dish", key = "#categoryId+'_'+#status")
    public ResultInfo<List<Dish>> findDish(Long categoryId, Integer status) {
        List<Dish> dishList = dishService.findDish(categoryId, status);
        return ResultInfo.success(dishList);
    }
}
